﻿#pragma once
#include "../common/BasePclProvider.h"

#include "pcl/includePcl.h"
#include <pcl/segmentation/region_growing.h>

#include "./PclRegionGrowingModel.h"

/// <summary>
/// PclRegionGrowingProvider
/// </summary>
class PclRegionGrowingProvider : public BasePclProvider
{
    Q_OBJECT

public:
    PclRegionGrowingProvider();

public:
    void initEditor(QtTreePropertyBrowser* editor);
    void valueChanged(QtProperty*, double) override;
    void valueChanged(QtProperty*, QString) override;
    void valueChanged(QtProperty*, int) override;
    void valueChanged(QtProperty*, bool) override;
    void valueChanged(QtProperty*, const QColor&) override;
    void close() override;
    void doLoadPcd();
    void doAction();

    /**
     * @brief Region growing segmentation
     * https://pcl.readthedocs.io/projects/tutorials/en/master/region_growing_segmentation.html
     * data:
     * https://raw.githubusercontent.com/PointCloudLibrary/data/master/tutorials/region_growing_tutorial.pcd
     * @param cloud
     * @param model
     * @return
     */
    void impl(pcl::PointCloud<pcl::PointXYZ>::Ptr cloud, PclRegionGrowingModel& model);

private:
    pcl::RegionGrowing<pcl::PointXYZ, pcl::Normal> reg_;
    pcl::PointCloud<pcl::PointXYZRGB>::Ptr resultCloud_;
};
